package service

import (
	"context"
	v1 "kratos-realworld/api/realworld/v1"
)

func (r *RealWorldService) Login(ctx context.Context, req *v1.LoginRequest) (*v1.UsersReply, error) {
	rv, err := r.userUC.Login(ctx, req.User.Email, req.User.Password)
	if err != nil {
		return nil, err
	}
	return &v1.UsersReply{
		User: &v1.UsersReply_User{
			Username: rv.Username,
			Token:    rv.Token,
		},
	}, nil
}

func (r *RealWorldService) Register(ctx context.Context, req *v1.RegisterRequest) (*v1.UsersReply, error) {
	u, err := r.userUC.Register(ctx, req.User.Username, req.User.Email, req.User.Password)
	if err != nil {
		return nil, err
	}
	return &v1.UsersReply{
		User: &v1.UsersReply_User{
			Username: u.Username,
			Token:    u.Token,
		},
	}, nil
}
func (r *RealWorldService) GetCurrentUser(context.Context, *v1.GetCurrentUserRequest) (*v1.UsersReply, error) {
	return &v1.UsersReply{}, nil
}
func (r *RealWorldService) UpdateUser(context.Context, *v1.UpdateUserRequest) (*v1.UsersReply, error) {
	return &v1.UsersReply{}, nil
}
func (r *RealWorldService) GetProfile(context.Context, *v1.GetProfileRequest) (*v1.ProfileReply, error) {
	return &v1.ProfileReply{}, nil
}
func (r *RealWorldService) FollowUser(context.Context, *v1.FollowUserRequest) (*v1.ProfileReply, error) {
	return &v1.ProfileReply{}, nil
}
func (r *RealWorldService) UnfollowUser(context.Context, *v1.UnfollowUserRequest) (*v1.ProfileReply, error) {
	return &v1.ProfileReply{}, nil
}
